﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Rtgs.master" AutoEventWireup="true" CodeFile="sys_t_loglist.aspx.cs" Inherits="page_usermanagement_sys_t_loglist" %>

<asp:Content ID="ctnBody" ContentPlaceHolderID="body" runat="server">
    <link type="text/css" rel="stylesheet" href="<%= ResolveClientUrl("~/css/ui.jqgrid.css") %>" />
    <script type="text/javascript" src="<%= ResolveClientUrl("~/script/i18n/grid.locale-en.js") %>"></script>
    <script type="text/javascript" src="<%= ResolveClientUrl("~/script/jquery.jqGrid.min.js") %>"></script>
    <script src="<%= ResolveClientUrl("~/script/helper.js") %>" type="text/javascript"></script>
     <script type="text/javascript" src="<%= ResolveClientUrl("~/script/jquery.fmatter.js") %>"></script>
    <div>
        
        <a href="#" id="dialog_link" class="dialog_link ui-state-default ui-corner-all" alt="Edit"
            onclick="OpenForm('edit');"><span class="ui-icon ui-icon-pencil"></span>View</a>
    </div>
   
    <br />
    <table id="table" class="scroll" cellpadding="0" cellspacing="0">
    </table>
    <div id="pager" class="scroll">
    </div>
    <br />
    <div id="dialog" title="Default dialog">
    </div>
    <script type="text/javascript">

        var handlerUrl = '<%= ResolveClientUrl("~/ajaxhandler/usermanagement/sys_t_log.ashx") %>';

        $('#table').jqGrid({
            url: handlerUrl + '?method=getdata',
            datatype: 'json',
            colNames: ['ID', 'User Name','Log Source', 'Log Event', 'Log Message', 'Date'],
            colModel: [

                { name: 'logId', hidden: true, index: 'LOG_ID', width: 60 },
                { name: 'createdBy', index: 'CREATED_BY', width: 100 },
           		{ name: 'logSource', index: 'LOG_SOURCE', width: 200 },
           		{ name: 'logEvent', index: 'LOG_EVENT', width: 300 },
           		{ name: 'logMessage', index: 'LOG_MESSAGE', width: 300 },
                { name: 'createdDate', index: 'CREATED_DATE', width: 150, sorttype: 'date', formatter: 'date', formatoptions: { newformat: 'd-m-Y H:i:s'} }
               
           	],
            rowNum: 10,
            id: 'LOG_ID',
            multiselect: true,
            rowList: [5, 10, 15, 20],
            pager: '#pager',
            sortname: 'CREATED_DATE',
            sortorder: "desc",
            viewrecords: true,
            jsonReader: { repeatitems: false },
            width: 'auto',
            height: '100%',
            caption: 'Log Event',
            ajaxGridOptions: { cache: false },
            ondblClickRow: function () {
                OpenForm('edit');
            }
        });

        function OpenForm(ctl) {

            var formUrl = '<%= ResolveClientUrl("~/form/usermanagement/sys_t_logform.aspx") %>';

            var grid = $('#table');
            var selIds = grid.jqGrid('getGridParam', 'selarrrow'),
                selText = [];
            $.each(selIds, function () {
                selText.push(grid.jqGrid('getCell', this, 'logId'));
            });

            if (ctl == 'edit') {
                $('#dialog').load(formUrl + '?id=' + selText).dialog({ modal: true, width: 500, title: 'Edit User' });
            }
//            else if (ctl == "add") {
//                $('#dialog').load(formUrl).dialog({ modal: true, width: 600, title: 'Add User' });
//            }
//            else {
//                var result = window.confirm('Are you sure that you want to delete?');
//                if (result) {
//                    CallAjax(handlerUrl, "?method=delete" + "&id=" + selText);

//                    setTimeout("$('#table').trigger('reloadGrid');", 3000);
//                }
//            }

        }
    </script>
</asp:Content>

